package com.ycw.controller.wang;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycw.bean.Comments;
import com.ycw.service.wang.CommentsService;
import com.ycw.util.Msg;

@Controller
public class WangwangCommentsController {

	@Autowired
	private CommentsService commentsService;

	@RequestMapping("/getComments")
	@ResponseBody
	public Msg getComments(@RequestParam(value = "pn", defaultValue = "1") Integer pn) {
		PageHelper.startPage(pn, 10);
		List<Comments> com = commentsService.getComments();
		PageInfo pageInfo = new PageInfo(com);
		return Msg.success().add("pageInfo", pageInfo);
	}

	@RequestMapping("/descComments")
	@ResponseBody
	public Msg descComments(@RequestParam(value = "pn", defaultValue = "1") Integer pn) {
		PageHelper.startPage(pn, 10);
		List<Comments> com = commentsService.descComments();
		PageInfo pageInfo = new PageInfo(com);
		return Msg.success().add("pageInfo", pageInfo);
	}

}
